home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 February / CHIP_CD_2001_02_PL.iso / Programy graficzne / Image Co-Tracker 2.0 / CoTrack2.exe / app.___ < prev    next >
Encoding:
Text File  |  2000-10-31  |  43.2 KB  |  1,636 lines

  1. <HTML>
  2. <HEAD> 
  3. <TITLE>Image Co-Tracker</TITLE>
  4. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
  5.   <HTA:APPLICATION ID="oMyApp" 
  6.     APPLICATIONNAME="{130C4DD1-7A96-11d4-BE19-00C0F0489117}"
  7.     BORDER="yes"
  8.     CAPTION="yes"
  9.     ICON=".\\bpad.ico"
  10.     SHOWINTASKBAR="yes"
  11.     SINGLEINSTANCE="yes"
  12.     SYSMENU="yes"
  13.     WINDOWSTATE="maximize">    
  14. </HTA:APPLICATION>    
  15. <OBJECT ID="Engine" CLASSID="CLSID:04AB20C2-D25A-11D3-A94C-00C0F048995B">
  16. </OBJECT>
  17.  
  18. <SCRIPT language="javascript">
  19.  
  20. // File2Tracker constants
  21. @set @NEW_XMLDB=0
  22. @set @OPEN_XMLDB=1
  23. @set @SAVE_XMLDB=2
  24.  
  25.  
  26. var gnImageNum = 0;
  27. var gIntId=null;
  28. var bOpenList = 0;
  29. var szPath, szProductPath;
  30. var bCallTPrint=0;
  31. var gnPicLoopCount = 0;          
  32. var idLoadPicIntv = 0;
  33. var bInsertOrRename = false;
  34. var bOk = false;
  35.  
  36.  
  37. szPath = new String (top.location.pathname);
  38. szPath = szPath.toLowerCase();
  39. if (szPath.charAt(0) == "/")
  40.  szPath = szPath.substring(1, szPath.length);
  41. nPos =  szPath.search ("app.hta");
  42. szProductPath = unescape(szPath.substring(0,nPos-1));
  43.  
  44. var    sz_XSLPath = szProductPath + "\\store.xsl";
  45.  
  46.  
  47. var    Source;
  48. var    Style;
  49. var    StyleFirst;
  50. //var    WshShell;
  51.  
  52. var sc_BeforeChange = "";
  53. var ChangeParent = null;
  54. var bNoRestore = 0;
  55. var idImgTimer = 0;
  56. var idTimeout = 0;
  57. var idDis = 0;
  58. var IEVersion;
  59.  
  60.  
  61. function SaveSource()
  62. {
  63.     var str; 
  64.  
  65.     // check XML base encoding         
  66.     if (Source.childNodes[0].attributes[1].nodeValue != "utf-8")
  67.      Source.childNodes[0].attributes[1].nodeValue ="utf-8";
  68.  
  69.     dbversion = Source.selectSingleNode ("root[@dbversion]");
  70.     if (dbversion == null)
  71.     {
  72.        Root = Source.selectSingleNode ("root");
  73.        Root.setAttribute ("dbversion", "1.0");
  74.     }
  75.  
  76.  
  77.     if (!Engine)
  78.      alert("Unable to create Image Co-Tracker object!");
  79.  
  80.     str = Engine.commitChanges(Source, 0);
  81.  
  82.     return str;
  83. }
  84.  
  85. function ChangeStringValue(ItemToChange)
  86. {   
  87.     
  88.     ChangeParent = ItemToChange.offsetParent; // BANNER
  89.     sc_BeforeChange = ChangeParent.innerHTML;
  90.     var sc_OldValue = ChangeParent.all.item("Value").innerText;
  91.     
  92.     ChangeParent.innerHTML = "<INPUT TYPE=TEXT CLASS=width80 onkeydown=top.ChangeOnKeyPress(this) id=TEXT1 name=TEXT1 onblur=top.MyClick()></INPUT>"
  93.     ChangeParent.firstChild.value = sc_OldValue;
  94.     ChangeParent.firstChild.select();
  95.     ChangeParent.firstChild.focus();
  96. }
  97.  
  98.  
  99. function GetSortMode ()
  100. {
  101.    var sz_Sort= top.frames[0].document.all.item("SortOrder").value;
  102.    switch (sz_Sort)
  103.    {
  104.     case "All categories":
  105.       return 0;
  106.     case "-@CreationDate":
  107.       return 1;
  108.     case "@Name; -@CreationDate":
  109.       return 2;
  110.     case "-@LastAccess":
  111.       return 3;
  112.     case "@Comment; -@CreationDate":
  113.       return 4;
  114.    case  "@ID_CATEGORY; -@CreationDate":
  115.       return 5;
  116.   }
  117.   return 0;
  118. }
  119.  
  120. function IsNeedSort (szSlotName)
  121. {
  122.  switch (szSlotName)
  123.  {
  124.   case "Name":
  125.    if (GetSortMode() == 2)
  126.     return 1;
  127.    else
  128.     return 0;
  129.     
  130.   case "Comment":
  131.    if (GetSortMode() == 4)
  132.     return 1;
  133.    else
  134.     return 0;
  135.     
  136.   case "Category":
  137.    if (GetSortMode() == 5)
  138.     return 1;
  139.    else
  140.     return 0;    
  141.  }
  142.  return 0;
  143. }
  144.  
  145. function OnListKeyDown (Select)
  146. {    
  147.     var Key=top.frames[1].event.keyCode;
  148.     if (Key == 27)    
  149.     {        
  150.         ChangeParent.innerHTML = sc_BeforeChange;
  151.         ChangeParent.focus();
  152.         bOpenList = 0;        
  153.         ChangeParent = null;
  154.     }
  155.     else
  156.      if (Key == 13)    
  157.      {       
  158.        ChangeBannerCategory(Select);
  159.        ChangeParent = null; 
  160.      }
  161. }
  162.  
  163.  
  164. function ChangeBannerCategory (Select)
  165.    var    Banner = Source.selectSingleNode("root\/BANNERBASE\/BANNER[@UIN="+ChangeParent.offsetParent.id+"]");
  166.    sc_NewValue = Select.options[Select.selectedIndex].value;
  167.    if (Banner != null)    
  168.    {
  169.      Banner.setAttribute("ID_CATEGORY", sc_NewValue);
  170.      szNewCTName = Select.options[Select.selectedIndex].text;
  171.      ChangeParent.innerHTML = sc_BeforeChange;         
  172.      ChangeParent.all.item("Value").innerText = szNewCTName;
  173.      ChangeParent.focus();         
  174.      Sort(1);          
  175.      ChangeParent = null; 
  176.    }       
  177.    bOpenList = 0;
  178. }
  179.  
  180.  
  181. // call XSL on category/change
  182. function ChangeCategoryValue(ItemToChange)
  183. {   
  184.   bOpenList = 1;
  185.  
  186.   var    CTListNames = Source.selectNodes("root\/CTLIST\/CATEGORY\/@Name");
  187.   var    CTListIDs =   Source.selectNodes("root\/CTLIST\/CATEGORY\/@CID");    
  188.   var   b_cat;
  189.   var    Banner;
  190.   var   k=0;
  191.   
  192.   if ((CTListNames == null) || (CTListIDs == null))
  193.    return;   
  194.   
  195.   ChangeParent = ItemToChange.offsetParent;
  196.   sc_BeforeChange = ChangeParent.innerHTML;    
  197.   var sc_OldValue = ChangeParent.all.item("Value").innerText;
  198.   ChangeParent.innerHTML = "<SELECT NAME=INT_CT_LIST ALIGN=ABSMIDDLE CLASS=width40p id=INTCTLIST onkeydown=top.OnListKeyDown(this) onblur=top.MyClick() onchange=top.ChangeBannerCategory(this) ondblclick=top.ChangeBannerCategory(this)><\SELECT>";  
  199.   
  200.   Banner = Source.selectSingleNode("root\/BANNERBASE\/BANNER[@UIN="+ChangeParent.offsetParent.id+"]");
  201.   if (Banner != null)
  202.    b_cat = Banner.getAttribute("ID_CATEGORY");
  203.    
  204.   for (i=0; i < CTListIDs.length; i++)
  205.   {  
  206.    var objOption= top.frames[1].document.createElement ("OPTION");
  207.    objOption.text = CTListNames[i].nodeValue;
  208.    objOption.value =CTListIDs[i].nodeValue;
  209.    if (Banner && (b_cat == objOption.value))
  210.     k=i;
  211.    top.frames[1].document.all["INT_CT_LIST"].options.add (objOption);   
  212.  }  
  213.  top.frames[1].document.all["INT_CT_LIST"].selectedIndex = k;
  214.  ChangeParent.firstChild.focus(); 
  215. }
  216.  
  217.  
  218. function ChangeOnInsertOrRename(Edit, bInsert, bMode)
  219.  var Key;
  220.  if (bMode)
  221.   Key=13;
  222.  else
  223.   Key=top.frames[0].event.keyCode;        //27 - Esc, 13 - Enter  
  224.  
  225.  if (Key == 27)    
  226.  {
  227.     ChangeParent.style.display = "none";    
  228.     ChangeParent.innerHTML = "";
  229.     ChangeParent.insertAdjacentHTML("beforeEnd", sc_BeforeChange);
  230.     ChangeParent.style.display = "";                
  231.     ChangeParent = null; 
  232.     return;
  233.  }
  234.  if (Key != 13)
  235.    return;  
  236.  
  237.  var   CatName = Edit.value;   
  238.  
  239.  if ((CatName == null) || (CatName == "") || (CatName == " ") || (CatName == "  "))
  240.  {   
  241.    alert ("The category name cannot be blank.");
  242.    //ChangeParent.firstChild.focus();
  243.    return;  
  244.  }
  245.    
  246.  
  247.   var    CTListNames = Source.selectNodes("root\/CTLIST\/CATEGORY\/@Name");
  248.   var    CIDs =   Source.selectNodes("root\/CTLIST\/CATEGORY\/@CID");  
  249.   var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  250.   
  251.   if (((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001")) && (!bInsert))
  252.   {
  253.    return;
  254.   }  
  255.   
  256.   var    Category =   Source.selectSingleNode("root\/CTLIST\/CATEGORY[@CID="+CurrentCT.nodeValue+"]");  
  257.   var   newCID = 0;
  258.    
  259.   for (i=0; i < CTListNames.length; i++)
  260.   {
  261.     if (CTListNames[i].nodeValue == CatName)
  262.     {
  263.         alert("This category already exists!");        
  264.             //ChangeParent.firstChild.focus();
  265.         return;
  266.     }
  267.   }  
  268.       
  269.  if (bInsert)   
  270.  {
  271.       for (Index = 0; Index < CIDs.length; Index++)    
  272.       {
  273.         if (parseInt(CIDs[Index].text, 10) > newCID)
  274.           newCID = parseInt(CIDs[Index].text, 10);
  275.       }
  276.       newCID++;
  277.       var    sc_CID = "0000000000000000" + newCID;
  278.       sc_CID = sc_CID.substr(sc_CID.length - 16); 
  279.   
  280.         // check empty page
  281.         var    Root = Source.selectSingleNode("root");
  282.         if (Root == null)
  283.         {
  284.             // insert processing instruction
  285.             ElXML = Source.createProcessingInstruction('xml', ' version="1.0" encoding="utf-8" ');                
  286.             Source.insertBefore(ElXML, null);                
  287.  
  288.             //  insert root element 
  289.             Root = Source.createElement("root");
  290.             Root.text = "\n\t";
  291.             Source.appendChild(Root);
  292.         }            
  293.         var    CtList = Source.selectSingleNode("root/CTLIST");            
  294.         if (CtList == null)    
  295.         {                
  296.             CtList = Source.createElement("CTLIST");
  297.             CtList.setAttribute("CurrentCategory", "0000000000000000");
  298.             CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  299.         }
  300.                     
  301.         CtNew = Source.createElement("CATEGORY");
  302.         CtNew.setAttribute("CID", sc_CID);                
  303.         CtNew.setAttribute("Name",  CatName);                
  304.         CtNew.text = "\n";
  305.                     
  306.         Root.appendChild(CtList);
  307.         CtList.appendChild(CtNew);    
  308.         
  309.         AddCTToList (CatName, sc_CID, CurrentCT.nodeValue);          
  310.     }
  311.     else
  312.     {     
  313.       Select=top.frames[0].document.all["CT_LIST"];    
  314.       Select.options[Select.selectedIndex].text=CatName; 
  315.       Category.setAttribute("Name",  CatName);      
  316.     }
  317.     
  318.     ChangeParent.style.display = "none";    
  319.     ChangeParent.innerHTML = sc_BeforeChange;        
  320.     ChangeParent.style.display = "";
  321.     if (bInsert)
  322.      SaveSource ();
  323.     else
  324.      Sort(1);     
  325.     ChangeParent = null; 
  326. }
  327.  
  328.  
  329. function UpdateDisabledButtons ()
  330. {
  331.  var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  332.    if ((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001"))
  333.     {
  334.      top.frames[0].document.all["btnDelCT"].src = "delct_d.gif";
  335.      top.frames[0].document.all["btnRenameCT"].src = "renct_d.gif";
  336.      top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "default";
  337.      top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "default";
  338.      top.frames[0].document.all["btnDelCT"].UpdateButton(1, 0);
  339.      top.frames[0].document.all["btnRenameCT"].UpdateButton(1, 0);
  340.     }
  341.     else
  342.     {
  343.      top.frames[0].document.all["btnDelCT"].src = "delct_g.gif";
  344.      top.frames[0].document.all["btnRenameCT"].src = "renct_g.gif";
  345.      top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "hand";
  346.      top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "hand";
  347.      top.frames[0].document.all["btnDelCT"].UpdateButton(0, 0);
  348.      top.frames[0].document.all["btnRenameCT"].UpdateButton(0, 0);
  349.     }
  350. }
  351.  
  352. function CheckToolbar ()
  353. {
  354.   if (top.frames[0].document.all["btnDelCT"]!=null)  
  355.   {
  356.     clearInterval (idDis);
  357.     UpdateDisabledButtons();
  358.   } 
  359. }
  360.  
  361.  
  362. function InsertOrRenameCategory (ItemToChange, bInsert)
  363. {
  364.    bOk = false;
  365.    var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  366.    if (((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001")) && (!bInsert))
  367.    { 
  368.      //alert ("This category cannot be renamed.");
  369.      return;
  370.     }        
  371.  
  372.     SetButtonImage(ItemToChange, 1);
  373.  
  374.     ChangeParent = ItemToChange.parentElement; //offsetParent;    
  375.     sc_BeforeChange = ChangeParent.innerHTML;    
  376.     if (bInsert)
  377.     {
  378.       ChangeParent.innerHTML = "<INPUT TYPE=TEXT id=idEdit onkeydown=top.ChangeOnInsertOrRename(this,1) onblur='setTimeout(\"top.MyClick()\", 500)' id=TEXTINSERT name=TEXTINSERT style='width:160px; height:20px;margin-bottom:9px; font-size:11px;'></INPUT><BUTTON TYPE=BUTTON ONCLICK='bOk=true;top.ChangeOnInsertOrRename(idEdit,1, true);return false;' style='margin-bottom:9px; font-family: Verdana,Arial; font-size: 8pt;'>ok</BUTTON>";      
  379.       ChangeParent.firstChild.value = "";
  380.     }
  381.     else
  382.     {
  383.       var    Category =   Source.selectSingleNode("root\/CTLIST\/CATEGORY[@CID="+CurrentCT.nodeValue+"]");        
  384.       CatName = Category.getAttribute("Name");
  385.       ChangeParent.innerHTML = "<INPUT TYPE=TEXT id=idEdit onkeydown=top.ChangeOnInsertOrRename(this,0) onblur='setTimeout(\"top.MyClick()\", 500)' id=TEXTRENAME name=TEXTRENAME style='width:160px; height:20px; margin-bottom:9px; font-size:11px;'></INPUT><BUTTON TYPE=BUTTON ONCLICK='bOk=true;top.ChangeOnInsertOrRename(idEdit,0, true);return false;' style='margin-bottom:9px; font-family: Verdana,Arial; font-size: 8pt;'>ok</BUTTON>";
  386.       ChangeParent.firstChild.value = CatName;
  387.       ChangeParent.firstChild.select();
  388.     }    
  389.  
  390.     ChangeParent.firstChild.focus();    
  391.     ChangeParent.firstChild.focus();
  392.     ChangeParent.firstChild.focus();    
  393.  
  394.     bInsertOrRename = true;
  395. }
  396.  
  397.  
  398. function DeleteCategory ()
  399. {  
  400.  
  401.    szCID = top.frames[0].document.all["CT_LIST"].options[top.frames[0].document.all["CT_LIST"].selectedIndex ].value;
  402.    
  403.    if ((szCID == "0000000000000000") || (szCID == "0000000000000001")) // all categories
  404.    {    
  405.     //alert ("This category cannot be deleted.");
  406.     return;    
  407.    }
  408.    
  409.    
  410.    if (szCID == "0000000000000001") // common category
  411.    {
  412.     //alert ("This category cannot be deleted.");
  413.     return;    
  414.    }
  415.  
  416.    if (top.confirm ("Do you want to delete a category and all the images it contains?") == 0)
  417.     return;
  418.  
  419.     
  420.     if (Source.readyState == 4)    
  421.     {        
  422.         var    Banners =   Source.selectNodes("root\/BANNERBASE\/BANNER[@ID_CATEGORY="+szCID+"]");  
  423.         var    Category =  Source.selectSingleNode("root\/CTLIST\/CATEGORY[@CID="+szCID+"]");  
  424.         
  425.         if (Category != null)
  426.           Category.parentNode.removeChild(Category);                 
  427.         
  428.         for (i = 0; i < Banners.length; i++)    
  429.         {         
  430.          var Banner = Banners[i];
  431.          Engine.DeleteImageFile (Banner);
  432.          Banner.parentNode.removeChild(Banner);
  433.          }        
  434.          top.frames[0].document.all["CT_LIST"].options.remove(top.frames[0].document.all["CT_LIST"].selectedIndex);
  435.          top.frames[0].document.all["CT_LIST"].selectedIndex = 0;                
  436.          
  437.          
  438.          //set "all categories"; save document, too
  439.          SetCategory();
  440.     }
  441. }
  442.  
  443.  
  444. function MyClick ()
  445. {   
  446.    //if ((!bInsertOrRename) && (!bOpenList)) 
  447.    if (!ChangeParent)
  448.     return;
  449.  
  450.    if (bInsertOrRename) 
  451.    {
  452.     bInsertOrRename = false;
  453.     idDis = setInterval (CheckToolbar, 400);
  454.     
  455.     if (bOk)
  456.     {
  457.         bOk=false;
  458.     return;
  459.     }
  460.    }
  461.     
  462.    if (bOpenList)
  463.     bOpenList = 0;   
  464.    ChangeParent.innerHTML = sc_BeforeChange;
  465.    
  466.    ChangeParent = null; 
  467. }
  468.  
  469.  
  470. function ChangeOnKeyPress(EditBox, bMode)
  471. {
  472.     var Key;
  473.     if (bMode)
  474.         key = 13;
  475.     else
  476.         Key=top.frames[1].event.keyCode;        //27 - Esc, 13 - Enter
  477.  
  478.     if (Key == 27)    
  479.     {
  480.         EditBox.style.display = "none";     
  481.         ChangeParent.innerHTML = sc_BeforeChange;
  482.         ChangeParent.focus();        
  483.         ChangeParent = null; 
  484.     }
  485.     else
  486.      if (Key == 13)    
  487.      {
  488.         var bDestroyMap = true;
  489.         bNoRestore = 1;  
  490.         var    Banner = Source.selectSingleNode("root\/BANNERBASE\/BANNER[@UIN="+ChangeParent.offsetParent.id+"]");
  491.         var sc_NewValue = EditBox.value;
  492.         ChangeParent.innerHTML = sc_BeforeChange;
  493.         if ((top.frames[1].document.all.item("" + ChangeParent.offsetParent.id + "-IMG").useMap != "") && (ChangeParent.all.item("Value").name == "Url"))
  494.         {
  495.             if (confirm("Changing the URL here will destroy the multiple URL references accosiated with the image.\nAre you sure?"))
  496.             {                
  497.                 ChangeParent.all.MURL.outerHTML = "";
  498.                 top.frames[1].document.all.item("" + ChangeParent.offsetParent.id + "-IMG").useMap = "";
  499.                 if (Banner != null)
  500.                 {
  501.                     Banner.setAttribute("Map", "");
  502.                     //SaveSource();
  503.                 }
  504.             }
  505.             else
  506.             {
  507.                 bDestroyMap = false;
  508.             }
  509.         }
  510.         if (bDestroyMap)
  511.         {
  512.             if (ChangeParent.all.item("Value").name == "Url")
  513.             {
  514.                 strl = sc_NewValue;
  515.                 str = new String (strl);
  516.                 if ((str.search ('://') == -1) && (str.search ('@') == -1) && (str.length>0))
  517.                 {             
  518.                  strl="http://"+strl;
  519.                  sc_NewValue = strl;
  520.                 }
  521.                 if ((str.search('@')!=-1) && (str.search('mailto:') == -1))
  522.                 {
  523.                     strl = "mailto:" + strl;
  524.                     sc_NewValue = strl;
  525.                 }            
  526.                 top.frames[1].document.all.item("" + ChangeParent.offsetParent.id + "-URL").href = sc_NewValue;                
  527.                 ChangeParent.all.item("Value").href=sc_NewValue;
  528.             }        
  529.             else if (ChangeParent.all.item("Value").name == "Name")
  530.             {
  531.                 top.frames[1].document.all.item("" + ChangeParent.offsetParent.id + "-IMG").alt = sc_NewValue;
  532.             }
  533.         
  534.             EditBox.style.display = "none";     
  535.             ChangeParent.all.item("Value").innerHTML = sc_NewValue;
  536.             ChangeParent.focus();        
  537.  
  538.             if (Banner != null)    
  539.             {
  540.              Banner.setAttribute(ChangeParent.all.item("Value").name, sc_NewValue);                          
  541.             }
  542.         }
  543.         bNoRestore = 0;        
  544.         if (IsNeedSort(ChangeParent.all.item("Value").name))        
  545.          Sort(1);
  546.         else
  547.          SaveSource();        
  548.  
  549.         ChangeParent = null; 
  550.      }
  551. }
  552.  
  553. function RealySort()
  554. {
  555.  Sort(1);  
  556.  top.focus();
  557. }
  558.  
  559.  
  560. function Sort( bSave )
  561. {    
  562.  
  563.     var SortOrder = top.frames[0].document.all.item("SortOrder");
  564.     if (SortOrder != null)    
  565.     {
  566.         var sz_Order = SortOrder.value;
  567.  
  568.         if (Source.readyState == 4)    
  569.         {
  570.             var Orders = Source.getElementsByTagName("root/BANNERBASE/@SortOrder");
  571.             for (var Index = 0; Index < Orders.length; Index++)
  572.                 Orders[Index].nodeValue = sz_Order;
  573.  
  574.             if (bSave) 
  575.              SaveSource();
  576.         }
  577.  
  578.         if (Style.readyState == 4)    
  579.         {
  580.             var Orders = Style.getElementsByTagName("*/xsl:for-each/@order-by");
  581.             var OrdersF = StyleFirst.getElementsByTagName("*/xsl:for-each/@order-by");
  582.  
  583.  
  584.             // set order for second xsl template
  585.             for (var Index = 0; Index < Orders.length; Index++)
  586.                 Orders[Index].nodeValue = sz_Order;
  587.  
  588.             // set order for first xsl template
  589.             for (var Index = 0; Index < OrdersF.length; Index++)
  590.                 OrdersF[Index].nodeValue = sz_Order;
  591.  
  592.             
  593.             DisplayDocument(1);
  594.         }
  595.     }
  596. }
  597.  
  598. function DeleteAll()
  599. {
  600.    
  601.     if (showModalDialog ("wrn.htm", "", "dialogWidth:292px; dialogHeight:140px; center:yes; border:thin; status:no; scroll:no; help:no;") == 0)
  602.      return;   
  603.  
  604.     if (Source.readyState == 4)    
  605.     {        
  606.         var    Banners = Source.getElementsByTagName("root/BANNERBASE/BANNER");
  607.  
  608.         for (i=0; i < Banners.length; i++)    
  609.         {
  610.             var    Banner = Banners[i];
  611.             Engine.DeleteAllImages (Banner.parentNode);
  612.             Banner.parentNode.removeChild(Banner);
  613.         }        
  614.  
  615.         Sort(1);        
  616.     }
  617. }
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624. function DeleteBanner(sz_Index)
  625. {
  626.     
  627.     if (Source.readyState == 4)    
  628.     {
  629.     
  630.         var ConfirmDelete = Source.selectSingleNode("root\/BANNERBASE\/@ConfirmDelete");  
  631.         if (ConfirmDelete &&  (ConfirmDelete.nodeValue == 1))
  632.          if (!confirm("Do you want to delete this image?"))
  633.           return;
  634.     
  635.         var    Banners = Source.selectNodes("root\/BANNERBASE\/BANNER[@UIN="+sz_Index+"]");
  636.  
  637.         if (Banners.length > 0)    
  638.         {
  639.             var    Banner = Banners[0];
  640.             Engine.DeleteImageFile (Banner);
  641.             Banner.parentNode.removeChild(Banner);
  642.         }        
  643.  
  644.         
  645.         SaveSource();            
  646.         CurElement = top.frames[1].event.srcElement;
  647.         Div=CurElement.parentElement.parentElement.parentElement.parentElement.parentElement;
  648.         Div.outerText="";        
  649.         if (!LoadPictures ())
  650.          setTimeout (LoadPictures, 100); 
  651.     }    
  652. }
  653.  
  654. function AccessBanner(sz_Index)
  655. {    
  656.  
  657.     if (Source.readyState == 4)    
  658.     {
  659.         var    Banner = Source.selectSingleNode("root\/BANNERBASE\/BANNER[@UIN="+sz_Index+"]");
  660.   
  661.         if (Banner != null)    
  662.         {
  663.             var    sc_Time = "0000000000000000" + Date.parse(new Date());
  664.             sc_Time = sc_Time.substr(sc_Time.length - 16);
  665.  
  666.             Banner.setAttribute("LastAccess", sc_Time);
  667.             SaveSource();                        
  668.             if (GetSortMode() == 3)
  669.              Engine.UpdateData (null);             
  670.         }
  671.     }
  672. }
  673.  
  674. function ReplaceCTToTop (newCIN)
  675. {
  676.  var    CTList = Source.selectSingleNode("root/CTLIST");
  677.  var    child = Source.selectSingleNode("root\/CTLIST\/CATEGORY[@CID="+newCIN+"]");  
  678.  var    childOldFirst = CTList.firstChild; 
  679.  
  680.     if (child && (child !== childOldFirst))
  681.     {
  682.      CTList.removeChild(child);
  683.      CTList.insertBefore(child, childOldFirst);
  684.      return 1;
  685.     }        
  686.     else
  687.      return 0;
  688. }
  689.  
  690.  
  691. function SetCategory ()
  692.  var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory"); 
  693.  var CIN = top.frames[0].document.all["CT_LIST"].options[top.frames[0].document.all["CT_LIST"].selectedIndex].value;
  694.  if (CurrentCT == null)
  695.   return;
  696.   
  697.  CurrentCT.nodeValue=CIN;
  698.  if ((CIN== "0000000000000000") || (CIN== "0000000000000001"))
  699.  {    
  700.    top.frames[0].document.all["btnRenameCT"].src = "renct_d.gif";
  701.    top.frames[0].document.all["btnDelCT"].src = "delct_d.gif";
  702.    top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "default";
  703.    top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "default";
  704.    top.frames[0].document.all["btnDelCT"].UpdateButton(1, 0);
  705.    top.frames[0].document.all["btnRenameCT"].UpdateButton(1, 0);
  706.  }
  707.  else
  708.  {
  709.    top.frames[0].document.all["btnRenameCT"].src = "renct_g.gif";
  710.    top.frames[0].document.all["btnDelCT"].src = "delct_g.gif";
  711.    top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "hand";
  712.    top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "hand";
  713.    top.frames[0].document.all["btnDelCT"].UpdateButton(0, 0);
  714.    top.frames[0].document.all["btnRenameCT"].UpdateButton(0, 0);
  715.  
  716.  }
  717.  
  718.  // replace current category to the top of the list
  719.  bb = ReplaceCTToTop (CIN); 
  720.  // sort/save
  721.  Sort (1);   
  722.  // fill category list anew
  723.  if (bb)
  724.   FillCTList ();
  725.  top.focus();  
  726.  
  727.  
  728. function AddCTToList (sz_Name, CID, CurrentCID)
  729. {  
  730.   var objOption= top.frames[0].document.createElement ("OPTION");
  731.   objOption.text =  sz_Name;
  732.   objOption.value = CID;
  733.   top.frames[0].document.all["CT_LIST"].options.add (objOption);    
  734.   if (CID == CurrentCID)
  735.     objOption.selected=true; 
  736.   else
  737.     objOption.selected=false;   
  738. }
  739.  
  740. function FillCTList ()
  741. {
  742.  var    CTList = Source.getElementsByTagName("root/CTLIST/CATEGORY");
  743.  var    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");
  744.  var    Sel = top.frames[0].document.all.CT_LIST;  
  745.    
  746.  while (Sel.options[1])   
  747.   Sel.options.remove(1);  
  748.   
  749.  
  750.  if (CTList == null)
  751.   return;
  752.   
  753.  for (i=0; i<CTList.length; i++)
  754.  {
  755.   var    Category = CTList[i];  
  756.   AddCTToList (Category.attributes[1].value, Category.attributes[0].value, CurrentCT == null ? null : CurrentCT.nodeValue);
  757.  }
  758.  
  759.  if ((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001"))
  760.  {                              
  761.    top.frames[0].document.all["btnDelCT"].src = "delct_d.gif";
  762.    top.frames[0].document.all["btnRenameCT"].src = "renct_d.gif";
  763.    top.frames[0].document.all["btnRenameCT"].runtimeStyle.cursor = "default";
  764.    top.frames[0].document.all["btnDelCT"].runtimeStyle.cursor = "default";
  765.    top.frames[0].document.all["btnDelCT"].UpdateButton(1, 0);
  766.    top.frames[0].document.all["btnRenameCT"].UpdateButton(1, 0);
  767.  }
  768. }
  769.  
  770.  
  771.  
  772. function LoadPictures()
  773.  var Height = 0;
  774.  var Image;
  775.  
  776.  if (idTimeout)
  777.   idTimeout = 0;
  778.  
  779.  
  780.  DIVs = top.frames[1].document.all.tags("DIV");
  781.  topMargin = top.frames[1].document.body.scrollTop;
  782.  bottomMargin = topMargin + top.frames[1].document.body.clientHeight;   
  783.  if (topMargin == bottomMargin)
  784.   return 0;  
  785.  
  786.  for (i=1; i < DIVs.length;i++)
  787.  { 
  788.    Image = DIVs[i].all.tags("IMG")[0];    
  789.    if ((Image) && (!Image.useMap))  
  790.    {
  791.     if ((Height+DIVs[i].scrollHeight >= topMargin) && (Height <= bottomMargin))
  792.     {
  793.      Image.src = Image.TEMPSRC;   
  794.     }
  795.     else
  796.     {
  797.      Image.src = ""; 
  798.     }
  799.    }     
  800.    Height += DIVs[i].scrollHeight;
  801.  } 
  802.  
  803.  return 1; 
  804. }
  805.  
  806.  
  807.  
  808.  
  809. function DisplayDocument(bFirst)
  810. {    
  811.  
  812.     if ((Source.readyState == 4) && (Style.readyState == 4) && (StyleFirst.readyState == 4))    
  813.     {    
  814.     
  815.         
  816.         var str;                
  817.  
  818.  
  819.    
  820.         if (bFirst) 
  821.         {
  822.          top.frames[1].document.all.item("XSLResult").style.display="none";
  823.  
  824.          sz_HTML = Source.transformNode(StyleFirst);                        
  825.          top.frames[1].document.all.XSLResult.innerHTML = sz_HTML;                
  826.         }
  827.         else
  828.         {
  829.          sz_HTML = Source.transformNode(Style);                        
  830.          top.frames[1].document.all.XSLResult.insertAdjacentHTML("beforeEnd", sz_HTML);
  831.         }
  832.         
  833.         var szText = "";           
  834.         
  835.         var MapsToEscape = top.frames[1].document.all.tags("MAP");
  836.         if (MapsToEscape != null)    
  837.         {
  838.             for (var Index = MapsToEscape.length - 1; Index >= 0; Index--)    
  839.             {
  840.                 MapsToEscape[Index].innerHTML = unescape(MapsToEscape[Index].innerHTML);                        
  841.             }
  842.         }                
  843.  
  844.         var MapsToChange = top.frames[1].document.all.tags("MAPTOCHANGE");
  845.         if (MapsToChange != null)    
  846.         {
  847.             for (var MapIndex = 0; MapIndex < MapsToChange.length; MapIndex++)    
  848.             {
  849.                 var AreasToChange = MapsToChange[MapIndex].parentElement.all.tags("AREA");
  850.                 if (AreasToChange != null)    
  851.                 {
  852.                     for (var AreaIndex = 0; AreaIndex < AreasToChange.length; AreaIndex++)    
  853.                     {
  854.                         AreasToChange[AreaIndex].target = "_blank";                        
  855.                     }
  856.                 }
  857.                 MapsToChange[MapIndex].parentElement.outerHTML = MapsToChange[MapIndex].nextSibling.outerHTML;                                        
  858.                 MapIndex--; // becouse there is decrement collection length                
  859.             }
  860.             
  861.         }                 
  862.  
  863.  
  864.         if (bFirst) 
  865.          top.frames[1].document.all.XSLResult.style.display="block";        
  866.           
  867.                   
  868.         if (bFirst  &&  (top.frames[1].document.all.tags("DIV").length == 31))                
  869.         {         
  870.          setTimeout("DisplayDocument(0)", 300);          
  871.         }
  872.  
  873.         
  874.         if (bFirst) 
  875.          setTimeout(LoadPictures, 50);         
  876.  
  877.     }
  878. }
  879.  
  880.  
  881. function ChangeXSL(sz_FileName)
  882. {    
  883.     var    b_Ok = Style.load(sz_FileName);
  884.  
  885.     StyleFirst.load("first.xsl");
  886.  
  887.     if (!b_Ok)
  888.         alert ("Error loading Image Co-Tracker StyleSheet (" + sz_FileName + ")");
  889.  
  890.     
  891.  
  892.     return    b_Ok;
  893. }
  894.  
  895. function SetNewBase (NewSourceXML, bMode)
  896. {    
  897.         ElXML = NewSourceXML.createProcessingInstruction('xml', ' version="1.0" encoding="utf-8" ');                
  898.         NewSourceXML.insertBefore(ElXML, null);                
  899.  
  900.         //  insert root element 
  901.         var Root = NewSourceXML.createElement("root");
  902.         Root.setAttribute("dbversion","1.0");
  903.         Root.text = "\n\t";
  904.         NewSourceXML.appendChild(Root);        
  905.                 
  906.         var CtList = NewSourceXML.createElement("CTLIST");
  907.         CtList.setAttribute("CurrentCategory", "0000000000000000");
  908.                 
  909.         var CtCommon = NewSourceXML.createElement("CATEGORY");
  910.         CtCommon.setAttribute("CID", "0000000000000001");                
  911.         CtCommon.setAttribute("Name", "Common");                
  912.         CtCommon.text = "\n";
  913.                 
  914.         Root.appendChild(CtList);
  915.         CtList.appendChild(CtCommon);
  916.  
  917.         var BannerBase = NewSourceXML.createElement("BANNERBASE");
  918.  
  919.         BannerBase.setAttribute("OpenMode", "_blank");
  920.         BannerBase.setAttribute("SortOrder", "-@CreationDate");
  921.         if (Engine.Options == -1)
  922.         {
  923.          BannerBase.setAttribute("ShowSlots", "191");
  924.          BannerBase.setAttribute("ConfirmDelete", "0");
  925.          BannerBase.setAttribute("SmallPictures", "0");
  926.          Engine.Options = 191;
  927.         }
  928.         else
  929.         {         
  930.          BannerBase.setAttribute("ShowSlots", Engine.Options & 255);
  931.  
  932.          if (Engine.Options & 1024)
  933.           BannerBase.setAttribute("ConfirmDelete", "1");
  934.          else
  935.           BannerBase.setAttribute("ConfirmDelete", "0");
  936.  
  937.          if (Engine.Options & 2048)
  938.           BannerBase.setAttribute("SmallPictures", "1");
  939.          else
  940.           BannerBase.setAttribute("SmallPictures", "0");
  941.         }
  942.  
  943.         BannerBase.text = "\n\t\t";
  944.  
  945.         Root.appendChild(BannerBase);
  946.         
  947.         if (bMode)
  948.         {
  949.             var str = Engine.GetXMLPath();
  950.             if (str)
  951.             {
  952.                 var szSrcPath = szProductPath + "\\1.png";
  953.                 Engine.CopyImageFile(szSrcPath, str);
  954.             }
  955.  
  956.             // insert banner with link to program's tutorial
  957.             var Banner = NewSourceXML.createElement("BANNER");
  958.         
  959.             Banner.setAttribute("UIN", "0000000000000001");
  960.             Banner.setAttribute("Name", "INTRODUCTION: HOW TO USE IMAGE CO-TRACKER");
  961.             Banner.setAttribute("Image", str + "1.png");
  962.             Banner.setAttribute("Width", "738");
  963.             Banner.setAttribute("Height", "359");
  964.             Banner.setAttribute("Url", "http://cogitum.com/co-tracker/howtouse.html");
  965.             Banner.setAttribute("Map", "");
  966.             Banner.setAttribute("IsMap", "false");        
  967.             Banner.setAttribute("Comment", "Launch Microsoft Internet Explorer 5.0 or higher. Click the right " + 
  968.             "mouse button on any Internet image, and select the Grab Image option from the pop-up menu. " + 
  969.             "Write in comments and select a category if you want, then click OK. To begin work with catalog of " + 
  970.             "'grabbed' images, click the Start button and select Image Co-Tracker from the Programs menu. " +
  971.             "For more information, click on the '?' icon on the toolbar.");
  972.             Banner.setAttribute("SourceUrl", "http://cogitum.com/co-tracker/howtouse.html");
  973.             Banner.setAttribute("LastAccess", "0000971160889000");
  974.             Banner.setAttribute("CreationDate", "0000971160889000");
  975.             Banner.setAttribute("IMGNode", "<IMG alt=Cogitum height=52 src="img/h_lhead.gif" width=284>");
  976.             Banner.setAttribute("ID_CATEGORY", "0000000000000001");
  977.             
  978.             BannerBase.appendChild(Banner);
  979.         }
  980.  
  981. }
  982.  
  983.  
  984. function ChangeXML()
  985. {    
  986.     var strCaption;    
  987.  
  988.     strCaption = Engine.OpenXMLBase (Source, 1, 0);     
  989.     if (!strCaption)
  990.     {    
  991.         SetNewBase (Source, true);
  992.         strCaption = SaveSource();
  993.         DisplayDocument(1);
  994.     }
  995.     else
  996.      CheckOptions();
  997.  
  998.  
  999.     var SortOrders = Source.getElementsByTagName("root/BANNERBASE/@SortOrder");
  1000.     if (SortOrders.length > 0)    
  1001.     {
  1002.         var SortOrder = top.frames[0].document.all.item("SortOrder");
  1003.         if (SortOrder != null)    
  1004.         {
  1005.             for (Index = 0; Index < SortOrder.options.length; Index++)    
  1006.             {
  1007.                 if (SortOrder.options(Index).value == SortOrders[0].nodeValue)
  1008.                     SortOrder.options(Index).selected = true;
  1009.             }
  1010.         }
  1011.     }
  1012.     else
  1013.      top.frames[0].document.all.item("SortOrder").value = "-@CreationDate"; 
  1014.  
  1015.     SetCaptionBar (strCaption);
  1016.     return    strCaption;
  1017. }
  1018.  
  1019. function AboutDlg ()
  1020. {
  1021.   showModalDialog ("about.htm", Engine, "dialogWidth=500px;dialogHeight=340px;center=yes;border=thin;status=no;scroll=no; help:no;");
  1022. }
  1023.  
  1024. function UsePrgDlg ()
  1025. {  
  1026.   showHelp ('ctrack.chm');
  1027. }
  1028.  
  1029. function ChooseCtListDlg ()
  1030. {
  1031.   bSave = showModalDialog ("choose.htm", Source, "dialogWidth=530px;dialogHeight=420px;center=yes;border=thin;status=no;scroll=no; help:no;");  
  1032.   if (bSave)  
  1033.   {
  1034.    SaveSource(); 
  1035.    FillCTList ();  
  1036.   }
  1037. }
  1038.  
  1039.  
  1040. function ShowOptions()
  1041.  
  1042.   var BBase = Source.selectSingleNode("root\/BANNERBASE");
  1043.   var ShowSlots = Source.selectSingleNode("root\/BANNERBASE\/@ShowSlots");    
  1044.   // for previous XML format compatible
  1045.   if (ShowSlots == null)    
  1046.   {                
  1047.    BBase.setAttribute("ShowSlots", 191);
  1048.    ShowSlots = Source.selectSingleNode("root\/BANNERBASE\/@ShowSlots");   
  1049.   }
  1050.   ShowSlotsVal = ShowSlots.nodeValue;
  1051.   var ConfirmDelete = Source.selectSingleNode("root\/BANNERBASE\/@ConfirmDelete");  
  1052.   if (ConfirmDelete == null)    
  1053.   {
  1054.    BBase.setAttribute("ConfirmDelete", 0);
  1055.    ConfirmDelete = Source.selectSingleNode("root\/BANNERBASE\/@ConfirmDelete");     
  1056.   }
  1057.   ConfirmDeleteVal = ConfirmDelete.nodeValue;
  1058.   var SmallPictures = Source.selectSingleNode("root\/BANNERBASE\/@SmallPictures");  
  1059.   if (SmallPictures == null)    
  1060.   {
  1061.    BBase.setAttribute("SmallPictures", "0");
  1062.    SmallPictures = Source.selectSingleNode("root\/BANNERBASE\/@SmallPictures");     
  1063.   }
  1064.   SmallPicturesVal = SmallPictures.nodeValue;
  1065.   
  1066.   if (isNaN(ShowSlotsVal))
  1067.     ShowSlotsVal = parseInt(ShowSlotsVal, 10);  
  1068.    
  1069.   var RowBitsOld = ShowSlotsVal;
  1070.   if (parseInt(ConfirmDeleteVal))
  1071.    RowBitsOld=RowBitsOld | 1024;
  1072.   if (parseInt(SmallPicturesVal))
  1073.    RowBitsOld=RowBitsOld | 2048;
  1074.    
  1075.   
  1076.    RowBits = showModalDialog ("options.htm", RowBitsOld, "dialogWidth:230px; dialogHeight:100px; dialogTop:150px; center:yes; border:thin; status:no; scroll:no; help:no;");
  1077.    if (RowBits != RowBitsOld)
  1078.    {
  1079.     Engine.Options = RowBits;
  1080.  
  1081.     if (top.frames[1].document.selection) 
  1082.      top.frames[1].document.selection.empty();
  1083.  
  1084.     if (RowBits & 1024)    
  1085.      BBase.setAttribute("ConfirmDelete", 1);     
  1086.     else
  1087.      BBase.setAttribute("ConfirmDelete", 0);     
  1088.      
  1089.      
  1090.      if  (RowBits & 2048)         
  1091.       BBase.setAttribute("SmallPictures", 1);     
  1092.      else 
  1093.       BBase.setAttribute("SmallPictures", 0);          
  1094.      BBase.setAttribute("ShowSlots", RowBits & 255);
  1095.      Sort(1);     
  1096.    }  
  1097.  
  1098. }
  1099.  
  1100.  
  1101.  
  1102. function ChangeXML_XSL(sz_XSLFileName)
  1103. {    
  1104.     if (ChangeXML())
  1105.         if (ChangeXSL(sz_XSLFileName))    
  1106.         {
  1107.             Sort(0);            
  1108.             return    true;
  1109.         }
  1110.  
  1111.     return    false;
  1112. }
  1113.  
  1114.  
  1115. function SetCaptionBar (str)
  1116. {
  1117.     if (str != null)
  1118.     {
  1119.      // set new captionbar
  1120.      str = "Image Co-Tracker - " + str;
  1121.      top.document.title = str;
  1122.     }      
  1123. }
  1124.  
  1125.  
  1126. function Init()
  1127. {   
  1128.    var str;
  1129.  
  1130.    IEVersion = window.navigator.appVersion.substring(22, 25);
  1131.    if (IEVersion.charAt(0) != '5')   
  1132.    {
  1133.      alert ("This program runs under Microsoft Internet Explorer 5.0 or higher only.");   
  1134.      top.close();
  1135.      return;
  1136.    }
  1137.  
  1138.    if (top.frames[0].document.body.clientHeight == 0)
  1139.    return;    
  1140.   
  1141.     Engine.HdWnd = 1;            
  1142.     
  1143.     //fs = new ActiveXObject("Scripting.FilesystemObject");      
  1144.     //WshShell = new ActiveXObject("WScript.Shell");
  1145.     
  1146.     Source = new ActiveXObject("Microsoft.XMLDOM");
  1147.     Source.async = false;            
  1148.  
  1149.     Style = new ActiveXObject("Microsoft.XMLDOM");
  1150.     Style.async = false;                    
  1151.  
  1152.     StyleFirst = new ActiveXObject("Microsoft.XMLDOM");
  1153.     StyleFirst.async = false;                    
  1154.     
  1155.     ChangeXML_XSL(sz_XSLPath);            
  1156.  
  1157.  
  1158.     FillCTList ();                        
  1159.  
  1160.     FnHead2ScreenSize();
  1161.  
  1162. //===================================================================================================================================================
  1163. //========================================== Find functions =========================================================================================
  1164.  
  1165. function TFind ()
  1166. {
  1167.   top.frames[1].focus();
  1168.   Engine.CallIECommand (0);
  1169. }
  1170.  
  1171. function OnFind ()
  1172. {
  1173.   top.frames[1].focus();
  1174.   setTimeout  (TFind, 500); 
  1175. }
  1176.  
  1177. //====================================================================================================================================================
  1178. //========================================== Print functions =========================================================================================
  1179.  
  1180. function TPrint ()
  1181. {  
  1182.   LoadAllPics();   
  1183.   if (gnImageNum > 0)
  1184.    idImgTimer = top.frames[1].setInterval (TWaitLoadImages, 20);  
  1185.   else
  1186.    fnPrint();
  1187. }
  1188.  
  1189. function OnPrint ()
  1190.   if (ConfirmPrint ()) 
  1191.   {
  1192.    top.frames[1].focus();
  1193.    top.frames[1].setTimeout (TPrint, 50);     
  1194.   }
  1195. }
  1196.  
  1197. function TWaitLoadImages ()
  1198. {
  1199.   if (CheckLoadingPics ())
  1200.    fnPrint();  
  1201. }
  1202.  
  1203.  
  1204. function fnPrint ()
  1205. {
  1206.   if (idImgTimer)
  1207.   {
  1208.    top.frames[1].clearInterval(idImgTimer);
  1209.    idImgTimer = 0;
  1210.   }
  1211.   top.frames[1].focus();
  1212.   Engine.CallIECommand (1);   
  1213. }
  1214.  
  1215. function ConfirmPrint ()
  1216. {
  1217.  var DIVs = top.frames[1].document.all.tags("DIV");   
  1218.   
  1219.  if ((DIVs.length > 150) && (!confirm ("You want to print more than 150 images. It may cause some troubles. Do you want to continue?")))
  1220.   return 0;
  1221.  else
  1222.   return 1;
  1223. }
  1224.  
  1225.  
  1226. function CheckLoadingPics ()
  1227. {
  1228.  var DIVs = top.frames[1].document.all.tags("DIV");  
  1229.  
  1230.  for (i=1; i < DIVs.length;i++)
  1231.  { 
  1232.    CurImage = DIVs[i].all.tags("IMG")[0];
  1233.    if (CurImage && (!CurImage.useMap) && (CurImage.fileSize) && (CurImage.readyState != "complete"))   
  1234.    {     
  1235.      return 0;
  1236.    }        
  1237.  } 
  1238.  return 1; 
  1239. }
  1240.  
  1241.  
  1242. function LoadAllPics ()
  1243.  var CurImage;
  1244.  var DIVs = top.frames[1].document.all.tags("DIV");  
  1245.  var NumImg;  
  1246.    
  1247.  NumImg = 0;
  1248.  for (i=1; i < DIVs.length;i++)
  1249.  { 
  1250.    CurImage = DIVs[i].all.tags("IMG")[0];
  1251.    if (CurImage && (!CurImage.useMap) && (CurImage.fileSize == -1))   
  1252.    {     
  1253.      NumImg++;
  1254.      CurImage.src = CurImage.TEMPSRC;   
  1255.    }        
  1256.  }   
  1257.  gnImageNum = NumImg;
  1258. }
  1259.  
  1260. function fnBeforePrint ()
  1261. {
  1262.  var Button;
  1263.  var DIVs = top.frames[1].document.all.tags("DIV");    
  1264.  
  1265.  for (i=1; i < DIVs.length;i++)
  1266.  { 
  1267.     Button = DIVs[i].all.tags("INPUT")[0];  
  1268.     if (Button)
  1269.      Button.style.display = "none";
  1270.  }   
  1271. }
  1272.  
  1273.  
  1274.  
  1275.  
  1276. function fnAfterPrint ()
  1277.  var Button;
  1278.  var DIVs = top.frames[1].document.all.tags("DIV");
  1279.  
  1280.  for (i=1; i < DIVs.length;i++)
  1281.  { 
  1282.     Button = DIVs[i].all.tags("INPUT")[0];
  1283.     if (Button)
  1284.      Button.style.display = "";
  1285.  }  
  1286. }
  1287.  
  1288. //============================================Head resize functions======================================================================================
  1289. function FnHead2ScreenSize ()
  1290. {    
  1291.   if (top.frames[0].document.body) 
  1292.    top.document.all.tags('FRAMESET')[0].rows = top.frames[0].document.body.scrollHeight + "px, *";
  1293. }
  1294.  
  1295.  
  1296. function FnHeadResize (HeadFrame)
  1297.   if (top.frames[0].document.body)   
  1298.    top.document.all.tags('FRAMESET')[0].rows = top.frames[0].document.body.scrollHeight + "px, *";  
  1299. }
  1300.  
  1301.  
  1302. //=======================================================================================================================================================
  1303.  
  1304. function SetButtonImage(oImg, bGray)
  1305. {
  1306.    var    CurrentCT;
  1307.  
  1308.    if (Source == null)
  1309.     return;
  1310.    
  1311.    CurrentCT = Source.selectSingleNode("root\/CTLIST\/@CurrentCategory");  
  1312.    if (((CurrentCT.nodeValue == "0000000000000000") || (CurrentCT.nodeValue == "0000000000000001")) && ((oImg.id == "btnDelCT") || (oImg.id == "btnRenameCT"))) 
  1313.     return;
  1314.  
  1315.  
  1316.  
  1317.  
  1318.   if (bGray == 1)
  1319.    oImg.src = oImg.graysrc;
  1320.   else
  1321.    oImg.src = oImg.colorsrc;
  1322. }
  1323.  
  1324. function File2Tracker (nCommand)
  1325. {
  1326.  var strCaption;
  1327.  
  1328.  switch (nCommand)
  1329.  {
  1330.    case @NEW_XMLDB:
  1331.     SourceNew = new ActiveXObject("Microsoft.XMLDOM");
  1332.     SourceNew.async = false;            
  1333.     SetNewBase (SourceNew);
  1334.     strCaption = Engine.NewXMLBase (SourceNew);
  1335.     if (strCaption)    
  1336.     {
  1337.      Source = SourceNew;         
  1338.      Engine.UpdateData(null);     
  1339.     }
  1340.     break;       
  1341.  
  1342.    case @OPEN_XMLDB:
  1343.     SourceNew = new ActiveXObject("Microsoft.XMLDOM");
  1344.     SourceNew.async = false;
  1345.     strCaption = Engine.OpenXMLBase (SourceNew, 0, 0);     
  1346.     if (strCaption)
  1347.     {
  1348.      Source = SourceNew;    
  1349.      Engine.UpdateData(null);     
  1350.     }
  1351.     break;       
  1352.  
  1353.    case @SAVE_XMLDB:    
  1354.     strCaption = Engine.SaveAsXMLBase (Source);     
  1355.     if (strCaption)    
  1356.       SetCaptionBar(strCaption);    
  1357.     break;        
  1358.  }
  1359.  
  1360. }
  1361.  
  1362.  
  1363. function CheckOptions ()
  1364. {
  1365.   var BBase = Source.selectSingleNode("root\/BANNERBASE");
  1366.   var ShowSlots = Source.selectSingleNode("root\/BANNERBASE\/@ShowSlots");    
  1367.   var ConfirmDelete = Source.selectSingleNode("root\/BANNERBASE\/@ConfirmDelete");    
  1368.   var SmallPictures = Source.selectSingleNode("root\/BANNERBASE\/@SmallPictures");  
  1369.   var CtOptions = Engine.Options;
  1370.   var Val;
  1371.   var bNoChange = true;
  1372.  
  1373.   //debugger;
  1374.  
  1375.   
  1376.   if (CtOptions == -1)    
  1377.   {
  1378.    Val = ShowSlots.nodeValue & 255;
  1379.    if ((ConfirmDelete) &&  (ConfirmDelete.nodeValue == 1)) 
  1380.     Val = Val | 1024;
  1381.    if ((SmallPictures) &&  (SmallPictures.nodeValue == 1)) 
  1382.     Val = Val | 2048;
  1383.    
  1384.    Engine.Options = Val;                   
  1385.   } 
  1386.   else
  1387.   {
  1388.    if ((!ShowSlots) ||  (ShowSlots.nodeValue != (CtOptions & 255)))
  1389.    {
  1390.     Val = CtOptions & 255;
  1391.     BBase.setAttribute("ShowSlots", Val);
  1392.     bNoChange = false;
  1393.    }
  1394.  
  1395.    if ((!ConfirmDelete) ||  (ConfirmDelete.nodeValue != (CtOptions & 1024)))
  1396.    {
  1397.     if ( CtOptions & 1024 )
  1398.      BBase.setAttribute("ConfirmDelete", 1);
  1399.     else    
  1400.      BBase.setAttribute("ConfirmDelete", 0);
  1401.     bNoChange = false;
  1402.    }
  1403.  
  1404.  
  1405.    if ((!SmallPictures) ||  (SmallPictures.nodeValue != (CtOptions & 2048)))
  1406.    {
  1407.     if ( CtOptions & 2048 )
  1408.      BBase.setAttribute("SmallPictures", 1);     
  1409.     else
  1410.      BBase.setAttribute("SmallPictures", 0);         
  1411.     bNoChange = false;
  1412.    }  
  1413.  
  1414.    if (bNoChange == false)
  1415.     SaveSource();
  1416.   }
  1417. }
  1418.  
  1419.  
  1420. function ExportF ()
  1421. {
  1422.   Engine.Export (null);
  1423. }
  1424.  
  1425. function ImportF ()
  1426. {
  1427.   Engine.Import (null);
  1428. }
  1429.  
  1430. function PublishHTML ()
  1431. {
  1432.  var HTMLText;
  1433.  var strDirName;
  1434.  
  1435.  str = Engine.GetHTMLName ();  
  1436.  
  1437.  if (str != null)
  1438.  {
  1439.      strTmp = str;
  1440.      strDir = "";
  1441.      do
  1442.      {
  1443.       nPos = strTmp.search (/\\/i);
  1444.       if (nPos != -1)      
  1445.       {
  1446.        strTmp = strTmp.substring (nPos+1, strTmp.length);
  1447.        strDir = str.substring (0, nPos+strDir.length+1);         
  1448.       }
  1449.      } while (nPos != -1); 
  1450.  
  1451.      nPos = strTmp.search (/\./);
  1452.      if (nPos != -1)
  1453.       strTmp = strTmp.substring (0, nPos);
  1454.      strDir = strDir + strTmp + "_images\\";
  1455.      strDirName = strTmp + "_images\\"; // name subdirectory with images
  1456.  
  1457.  
  1458.    var PSlotsOld = Source.selectSingleNode("root\/BANNERBASE\/@PubSlots");    
  1459.    var BBase = Source.selectSingleNode("root\/BANNERBASE");
  1460.  
  1461.    if (PSlotsOld == null)   
  1462.    {
  1463.     PSlotsOld = Source.selectSingleNode("root\/BANNERBASE\/@ShowSlots");    
  1464.     if (PSlotsOld)
  1465.      BBase.setAttribute("PubSlots", PSlotsOld.nodeValue);
  1466.     else
  1467.     {
  1468.      BBase.setAttribute("PubSlots", "191"); 
  1469.      PSlotsOld = Source.selectSingleNode("root\/BANNERBASE\/@PubSlots");    
  1470.     }
  1471.     SaveSource();
  1472.    }
  1473.  
  1474.    var PNamesOld = Source.selectSingleNode("root\/BANNERBASE\/@FieldNames");    
  1475.    if (PNamesOld == null)   
  1476.    {
  1477.     BBase.setAttribute("FieldNames", "1"); 
  1478.     PNamesOld = Source.selectSingleNode("root\/BANNERBASE\/@FieldNames");    
  1479.     SaveSource();
  1480.    }
  1481.  
  1482.    if (PNamesOld.nodeValue == 1)
  1483.     nSlots = PSlotsOld.nodeValue | 1024;
  1484.    else
  1485.     nSlots = PSlotsOld.nodeValue;
  1486.  
  1487.    var nSlots = showModalDialog ("pub_opts.htm", nSlots, "dialogWidth:230px; dialogHeight:100px; dialogTop:150px; center:yes; border:thin; status:no; scroll:no; help:no;");
  1488.    if (!nSlots)
  1489.     return;
  1490.  
  1491.    if ((nSlots & 191)  != PSlotsOld.nodeValue)
  1492.    {
  1493.     BBase.setAttribute("PubSlots", (nSlots & 191));
  1494.     SaveSource();
  1495.    }
  1496.  
  1497.    if ((nSlots & 1024) != PNamesOld.nodeValue)
  1498.    {
  1499.     if (nSlots & 1024)
  1500.      BBase.setAttribute("FieldNames", "1"); 
  1501.     else
  1502.      BBase.setAttribute("FieldNames", "0"); 
  1503.    }
  1504.  
  1505.  
  1506.    XSL4HTML = new ActiveXObject("Microsoft.XMLDOM");
  1507.    XSL4HTML.load("htm.xsl");
  1508.    HTMLText = Source.transformNode(XSL4HTML);
  1509.    top.frames[2].document.all.XSLResult.innerHTML = HTMLText;
  1510.  
  1511.    var MapsToEscape = top.frames[2].document.all.tags("MAP");
  1512.    if (MapsToEscape != null)    
  1513.     {
  1514.        for (var Index = MapsToEscape.length - 1; Index >= 0; Index--)                
  1515.          MapsToEscape[Index].innerHTML = unescape(MapsToEscape[Index].innerHTML);                                    
  1516.     }                
  1517.  
  1518.     var MapsToChange = top.frames[2].document.all.tags("MAPTOCHANGE");
  1519.     if (MapsToChange != null)    
  1520.     {
  1521.             for (var MapIndex = 0; MapIndex < MapsToChange.length; MapIndex++)    
  1522.             {
  1523.                 var AreasToChange = MapsToChange[MapIndex].parentElement.all.tags("AREA");
  1524.                 if (AreasToChange != null)    
  1525.                 {
  1526.                     for (var AreaIndex = 0; AreaIndex < AreasToChange.length; AreaIndex++)    
  1527.                      AreasToChange[AreaIndex].target = "_blank";                                            
  1528.                 }
  1529.                 MapsToChange[MapIndex].parentElement.outerHTML = MapsToChange[MapIndex].nextSibling.outerHTML;                                        
  1530.                 MapIndex--; // becouse there is decrement collection length                
  1531.             }
  1532.             
  1533.     }                 
  1534.  
  1535.    var Imgs = top.frames[2].document.all.tags("IMG");
  1536.    for (i=0; i<Imgs.length; i++)
  1537.    {
  1538.     StrSrc =  unescape (Imgs[i].src);    
  1539.     Engine.CopyImageFile (Imgs[i].src, strDir);    
  1540.     do
  1541.     {
  1542.       nPos = StrSrc.search ('/');
  1543.       if (nPos != -1)      
  1544.        StrSrc = StrSrc.substring (nPos+1, StrSrc.length);         
  1545.      } while (nPos != -1);
  1546.  
  1547.      StrSrc = strDirName + StrSrc;          
  1548.      Imgs[i].src = StrSrc;
  1549.    }
  1550.  
  1551.    HTMLText = top.frames[2].document.all.XSLResult.innerHTML;
  1552.    HTMLText = "<HTML><BODY STYLE='background-color:white'>" + HTMLText + "</BODY></HTML>"
  1553.    top.frames[2].document.all.XSLResult.innerHTML = "";
  1554.  
  1555.    var fso = new ActiveXObject("Scripting.FilesystemObject");
  1556.    var fstream = fso.CreateTextFile (str, true, true);
  1557.    fstream.Write (HTMLText);   
  1558.    fstream.Close ();
  1559.  
  1560.  }
  1561.    
  1562. }    
  1563.  
  1564.  
  1565. function fnContextMenuBubble ()
  1566. {
  1567.  if (event) 
  1568.  {
  1569.   event.cancelBubble = true;
  1570.   event.returnValue = false;
  1571.  }
  1572.  else
  1573.  {
  1574.   top.frames[0].event.cancelBubble = true;
  1575.   top.frames[0].event.returnValue = false;
  1576.  }
  1577.  
  1578.  return false;
  1579. }
  1580.  
  1581.  
  1582. function fnContextMenuCheck ()
  1583. {
  1584.  if ((top.frames[1].event.srcElement.tagName != "IMG") && (top.frames[1].event.srcElement.tagName != "INPUT"))
  1585.  {  
  1586.   top.frames[1].event.cancelBubble = true;
  1587.   top.frames[1].event.returnValue = false;
  1588.   return false;
  1589.  }
  1590. }
  1591.  
  1592.  
  1593. function Attach2Email (bPopup)
  1594. {
  1595.   //top.frames[0].document.all["btnMail"].UpdateButton(0, 1);
  1596.   if (top.frames[0].event)
  1597.   {
  1598.    x = top.frames[0].event.x;
  1599.    y = top.frames[0].event.y;
  1600.   }
  1601.   else
  1602.   {
  1603.    x=0;
  1604.    y=50; 
  1605.   }
  1606.  
  1607.   if (bPopup)
  1608.    Engine.MailClientsPopupMenu  (1, x, y);
  1609.   else
  1610.    Engine.MailClientsPopupMenu  (0, x, y);
  1611.  
  1612.   //top.frames[0].document.all["btnMail"].UpdateButton(0, 0);
  1613.   top.window.focus();
  1614. }
  1615.  
  1616. </SCRIPT>
  1617. </HEAD>
  1618. <FRAMESET BORDER=0 ROWS="40px, *, 0px" ID=Main onload="Init()" oncontextmenu="fnContextMenuBubble()">
  1619. <FRAME FRAMEBORDER=1 SCROLLING=NO SRC=hd.htm APPLICATION="yes" onresize="FnHeadResize (this)" NORESIZE> 
  1620. <FRAME FRAMEBORDER=0 SCROLLING=AUTO SRC=data.htm  APPLICATION="yes" onresize="LoadPictures()" NORESIZE>
  1621. <FRAME SRC=data.htm style="display:none" APPLICATION="yes" NORESIZE>
  1622. <NOFRAMES> There is no frame support!  </NOFRAMES>
  1623. </FRAMESET>
  1624. </HTML>
  1625.